#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool isValid(vector<vector<int>> &data, int row, int col, int ch)
{
  for (int i = 0; i < 9; i++)
  {
    if (data[row][i] == ch)
    {
      return false;
    }
    if (data[i][col] == ch)
    {
      return false;
    }
    if (data[(row / 3) * 3 + i / 3][(col / 3) * 3 + i % 3] == ch)
    {
      return false;
    }
  }
  return true;
}

bool dfs(vector<vector<int>> &data, int row, int col)
{
  // base case
  if (9 == col)
  {
    //row=row+1; // 下一行
    //col=0;
    return dfs(data, row + 1, 0);
  }

  if (row == data.size())
  {
    return true;
  }

  if (data[row][col] != 0)
  {
    return dfs(data, row, col + 1);
  }

  // 正常dfs
  for (int ch = 1; ch <= 9; ch++)
  {

    if (!isValid(data, row, col, ch))
    {
      continue;
    }

    data[row][col] = ch;
    if (dfs(data, row, col + 1))
    {
      return true;
    }

    data[row][col] = 0;
  }
  return false;
}

int main()
{
  vector<vector<int>> data(9, vector<int>(9));
  for (int i = 0; i < 9; i++)
  {
    for (int j = 0; j < 9; j++)
    {
      cin >> data[i][j];
    }
  }
  if (dfs(data, 0, 0))
  {
    // 打印data
    for (int i = 0; i < 9; i++)
    {
      for (int j = 0; j < 9; j++)
      {
        cout << data[i][j] << ' ';
      }
      cout << endl;
    }
  }

  return 0;
}